
#pragma once

#include <stdio.h>

struct Obj;
struct Id;
struct AllocContext;

/*
 * retrieves an element in the list given which goes right after first
 * occurence of the keyword identifier given.
 * If there is no such an element in the list, null pointer will be returned
 */
struct Obj *
get_list_elem_by_keyword( struct List * list, const struct Id * keyword );

/*
 * compares ids with each other
 * returns:
 *  0   if they are equal
 * -1   if left one is less than right one
 *  1   if left one is greater than right one
 */
int idcmp( const struct Id * lhs, const struct Id * rhs );

/*
 * compares two lists with each other
 * result shall be interpreted as in the idcmp functions
 */
int listcmp( const struct List * lhs, const struct List * rhs );

/*
 * compares objects with each other
 * returns:
 *  0   if they are equal
 * -1   if left one is less than right one
 *  1   if left one is greater than right one
 *
 * when objects that have different types are compared, the following takes into an account:
 * NIL < T < ID < NUM < STR < LIST
 * e.g.: object that has type OBJ_T considered less than object that has type OBJ_ID and etc.
 */
int objcmp( const struct Obj * lhs, const struct Obj * rhs );

/*
 * compares not the identifiers, but their namespaces
 */
int
cmp_ids_namespaces( const struct Id * lhs, const struct Id * rhs );

/*
 * prints certain element
 */
void print_obj( struct Obj * obj, FILE * fout );

/*
 * dumps memory usage within context
 */
void dump_mem_state( struct AllocContext * c, FILE * fout );
